#ifndef xpack_lang_cxx_align_center
#define xpack_lang_cxx_align_center
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::lang_cxx::inc
#include"define/base_type.hpp"
#include"lang/cxx/pad_bends.hpp"
#include"lang/cxx/clone.hpp"
#include"lang/cxx.hpp"
#pragma pop_macro("xuser")

namespace mixc::lang_cxx{
    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::align_center(uxx width, xalloc_t const & alloc) const {
        return xthe.align_center(width, ' ', ' ', alloc);
    }

    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::align_center(uxx width, item_cref_t pad, xalloc_t const & alloc) const {
        return xthe.align_center(width, pad, pad, alloc);
    }

    template<class item_t>
    template<class xalloc_t, class ret_t, class>
    inline ret_t cxx<item_t>::align_center(
        uxx                 width, 
        item_cref_t         pad_left, 
        item_cref_t         pad_right, 
        xalloc_t    const & alloc
    ) const {
        if (ixx r = ixx(xthe->length - width); r >= 0){
            return xthe.shorten(uxx(r)).clone(alloc);
        }
        else{
            uxx w     = uxx(-r);
            uxx left  = w / 2;
            uxx right = w - left;
            return xthe.pad_bends(left, right, pad_left, pad_right, alloc);
        }
    }
}

#endif
